home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / gfx / 3d / irit50src.lha / irit5 / symb_lib / symb_err.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-01  |  3.9 KB  |  75 lines

  1. /******************************************************************************
  2. * Symb_err.c - handler for all symb library fatal errors.              *
  3. *******************************************************************************
  4. * Written by Gershon Elber, May. 91.                          *
  5. ******************************************************************************/
  6.  
  7. #include "symb_loc.h"
  8.  
  9. typedef struct SymbErrorStruct {
  10.     SymbFatalErrorType ErrorNum;
  11.     char *ErrorDesc;
  12. } SymbErrorStruct;
  13.  
  14. static SymbErrorStruct ErrMsgs[] =
  15. {
  16.     { SYMB_ERR_WRONG_SRF,        "Provided surface type is wrong" },
  17.     { SYMB_ERR_BZR_CRV_EXPECT,        "Bezier curve is expected" },
  18.     { SYMB_ERR_BZR_SRF_EXPECT,        "Bezier surface is expected" },
  19.     { SYMB_ERR_BSP_CRV_EXPECT,        "Bspline curve is expected" },
  20.     { SYMB_ERR_BSP_SRF_EXPECT,        "Bspline surface is expected" },
  21.     { SYMB_ERR_RATIONAL_EXPECTED,    "Rational Crv/Srf expected." },
  22.     { SYMB_ERR_NO_CROSS_PROD,        "No cross product for scalar surface" },
  23.     { SYMB_ERR_POWER_NO_SUPPORT,    "Power basis type is not supported" },
  24.     { SYMB_ERR_CRV_FAIL_CMPT,        "Cannot make curves compatible" },
  25.     { SYMB_ERR_SRF_FAIL_CMPT,        "Cannot make surfaces compatible" },
  26.     { SYMB_ERR_UNDEF_CRV,        "Undefined curve type" },
  27.     { SYMB_ERR_UNDEF_SRF,        "Undefined surface type" },
  28.     { SYMB_ERR_UNDEF_GEOM,        "Undefined geometry type" },
  29.     { SYMB_ERR_OUT_OF_RANGE,        "Data is out of range." },
  30.     { SYMB_ERR_DIR_NOT_CONST_UV,    "Dir is not one of CONST_U/V_DIR" },
  31.     { SYMB_ERR_REPARAM_NOT_MONOTONE,    "Reparametrization is not monotone" },
  32.     { SYMB_ERR_BSPLINE_NO_SUPPORT,    "Bspline basis type is not supported" },
  33.     { SYMB_ERR_WRONG_PT_TYPE,        "Provided point type is wrong" },
  34.     { SYMB_ERR_ONLY_2D_OR_3D,        "Only two or three dimensions are supported" },
  35.     { SYMB_ERR_RATIONAL_NO_SUPPORT,    "Rational function is not supported" },
  36.     { SYMB_ERR_SRFS_INCOMPATIBLE,    "Surfaces for requested operation are incompatible" },
  37.     { SYMB_ERR_CRVS_INCOMPATIBLE,    "Curves for requested operation are incompatible" },
  38.     { SYMB_ERR_CANNOT_COMP_NORMAL,    "Cannot compute normal" },
  39.     { SYMB_ERR_TOO_COMPLEX,        "Too complex" },
  40.     { SYMB_ERR_UNSUPPORT_PT,        "Unsupported point type" },
  41.     { SYMB_ERR_W_NOT_SAME,        "Weights are not identical" },
  42.     { SYMB_ERR_SCALAR_EXPECTED,        "Scalar entity expected" },
  43.     { SYMB_ERR_POLY_CONST_SRF,        "Constant surfaces cannot be converted to polygons" },
  44.  
  45.     { SYMB_ERR_UNDEFINE_ERR,    NULL }
  46. };
  47.  
  48. /*****************************************************************************
  49. * DESCRIPTION:                                                               M
  50. * Returns a string describing a the given error. Errors can be raised by     M
  51. * any member of this symb library as well as other users. Raised error will  M
  52. * cause an invokation of SymbFatalError function which decides how to handle M
  53. * this error. SymbFatalError can for example, invoke this routine with the   M
  54. * error type, print the appropriate message and quit the program.            M
  55. *                                                                            *
  56. * PARAMETERS:                                                                M
  57. *   ErrorNum:   Type of the error that was raised.                           M
  58. *                                                                            *
  59. * RETURN VALUE:                                                              M
  60. *   char *:     A string describing the error type.                          M
  61. *                                                                            *
  62. * KEYWORDS:                                                                  M
  63. *   SymbDescribeError, error handling                                        M
  64. *****************************************************************************/
  65. char *SymbDescribeError(SymbFatalErrorType ErrorNum)
  66. {
  67.     int i = 0;
  68.  
  69.     for ( ; ErrMsgs[i].ErrorDesc != NULL; i++)
  70.     if (ErrorNum == ErrMsgs[i].ErrorNum)
  71.         return ErrMsgs[i].ErrorDesc;
  72.  
  73.     return "Undefined error";
  74. }
  75.